package com.study.lxy.netty.bio;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 简单的服务器类，基于BIO实现
 */
public class SimpleService {

    public static void main(String[] args) throws IOException {
        int port = 8080;
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(8080);
            while (true){
                Socket clientSocket = serverSocket.accept();
                new Thread(new ServerSocketHandler(clientSocket)).start();
            }
        } finally {
            if(serverSocket != null){
                serverSocket.close();
            }
        }

    }

}
